package bTree.LeetCode;

public class 最长特殊序列2 {
    public int findLUSlength(String[] strs) {
        int maxLength = -1;
        int length = strs.length;
        for (int i = 0; i < length; i++) {
            String str = strs[i];
            for (int j = 0; j < length ; j++) {
                if(j==i){
                    continue;
                }
                String str1 = strs[j];
                if (containsQueue(str1,str)) {
                    break;
                }
                if (i==length-1&&j==length-2){
                    maxLength = Math.max(maxLength, str.length());
                }
                if (j == length - 1) {
                    maxLength = Math.max(maxLength, str.length());
                }
            }
        }
        return maxLength;
    }

    private boolean containsQueue(String str1, String str) {
        int length1 = str1.length();
        int length = str.length();
        int left=0,right=0;
       while (left<=length1-1&&right<=length-1){
           if (str1.charAt(left)==str.charAt(right)){
               right++;
           }
           left++;
       }
       return right==length;
    }
}